package org.zhang.boot.util;

public class StringUtil {
    public static String replaceLast(String original, String target, String replacement) {
        int lastIndex = original.lastIndexOf(target);
        if (lastIndex == -1) {
            // 如果未找到目标字符串，返回原始字符串
            return original;
        }

        // 将原始字符串中最后一个目标字符串替换为新字符串
        return original.substring(0, lastIndex) + replacement + original.substring(lastIndex + target.length());
    }
}
